Skip to content

fix(rate-limit): make unstable resource fields optional and allow passthrough#3

Open
qyo123oyq wants to merge 1 commit into
MissionSquad:mainfrom
qyo123oyq:fix/rate-limit-schema
Open

fix(rate-limit): make unstable resource fields optional and allow passthrough#3
qyo123oyq wants to merge 1 commit into
MissionSquad:mainfrom
qyo123oyq:fix/rate-limit-schema

Conversation

@qyo123oyq

@qyo123oyq qyo123oyq commented Jun 24, 2026

Copy link
Copy Markdown

Problem

get_rate_limit fails with:

MCP error -32603: Invalid input: [{"code":"invalid_type","expected":"object","received":"undefined","path":["resources","code_scanning_upload"],"message":"Required"}]

Root cause

RateLimitSchema in src/operations/rate_limit.ts marks every resource field as required (z.object defaults to required). GitHub's /rate_limit response no longer includes code_scanning_upload, and the set of resource fields varies by account type and over time, so RateLimitSchema.parse(response) throws on real responses.

Changes

In src/operations/rate_limit.ts:

  • Keep core, search, graphql required (always present in practice).
  • Mark integration_manifest, code_scanning_upload, actions_runner_registration, scim, dependency_snapshots as .optional().
  • Add .passthrough() on the resources object so newly introduced resource fields don't break parsing.

Verification

Against the live GitHub API, get_rate_limit now returns the full payload instead of throwing. The real response contains 14 resource entries — code_scanning_upload is absent (confirming the root cause), and 7 fields not present in the schema (source_import, code_scanning_autofix, dependency_sbom, audit_log, audit_log_streaming, code_search, copilot_usage_records) are now tolerated by .passthrough().

Sample (excerpt):

{
  "resources": {
    "core": { "limit": 5000, "used": 2, "remaining": 4998, "reset": 1782318768 },
    "search": { "limit": 30, "used": 0, "remaining": 30, "reset": 1782315333 },
    "graphql": { "limit": 5000, "used": 0, "remaining": 5000, "reset": 1782318873 },
    "integration_manifest": { "limit": 5000, "used": 0, "remaining": 5000, "reset": 1782318873 },
    "actions_runner_registration": { "limit": 10000, "used": 0, "remaining": 10000, "reset": 1782318873 },
    "scim": { "limit": 15000, "used": 0, "remaining": 15000, "reset": 1782318873 },
    "dependency_snapshots": { "limit": 100, "used": 0, "remaining": 100, "reset": 1782315333 },
    "source_import": { "limit": 100, "used": 0, "remaining": 100, "reset": 1782315333 },
    "audit_log": { "limit": 1750, "used": 0, "remaining": 1750, "reset": 1782318873 },
    "code_search": { "limit": 10, "used": 0, "remaining": 10, "reset": 1782315333 }
  },
  "rate": { "limit": 5000, "used": 2, "remaining": 4998, "reset": 1782318768 }
}

Build passes (yarn buildtsc && shx chmod +x dist/*.js) with no errors.


🤖 AI usage disclosure: The bug analysis, patch, build verification, and the live get_rate_limit API test for this PR were produced with assistance from an AI coding agent (ZCode). The change was validated end-to-end against the live GitHub API. Submitted at the human contributor's request and under their review; human author confirms the patch and description are accurate.

…sthrough

GitHub's /rate_limit response no longer includes `code_scanning_upload`,
and the set of resource fields varies by account type/period. The current
schema marks all resource fields as required, so `RateLimitSchema.parse()`
throws on real responses (e.g. MCP error -32603: ...code_scanning_upload
Required).

- Keep core/search/graphql required (always present).
- Mark integration_manifest, code_scanning_upload,
  actions_runner_registration, scim, dependency_snapshots as optional.
- Add .passthrough() so newly introduced resource fields don't break
  parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant